<!--
 * @Descripttion: 
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2021-06-24 10:20:20
 * @LastEditTime: 2023-04-20 16:28:35
 * @FilePath: \cscec-pms-admin\src\views\index\components\ExtendModules.vue
-->
<template>
  <!-- 扩展功能 -->
  <ul class="extend-wrapper">
    <li
      v-for="({key,background,name,disabled,loading}) in extendList"
      :key="key"
      v-loading="loading"
      class="extend-item"
      :class="{'disabled-card':disabled}"
      @click="handleDetail(key)"
    >
      <span class="show">展示</span>
      <img
        class="extend-item-bg"
        :src="background"
        alt=""
      >
      <div class="extend-item-content">
        <p>{{ name }}</p>
        <div class="extend-item-image">
          <!-- <img
            class="extend-item-icon"
            :src="icon"
            alt=""
          > -->
        </div>
      </div>
    </li>
  </ul>
</template>

<script>
import Vue from 'vue'
import request from '@/utils/request'
export default {
  name: 'ExtendModules',
  data() {
    return {
      extendList: [
        {
          key: 'projectMap',
          background: require('@/assets/indexPage/extend-1.png'),
          // icon: require('@/assets/indexPage/extend-1-icon.png'),
          name: '工程大数据',
          loading: false
          // disabled: true
        },
        {
          key: 'video',
          background: require('@/assets/indexPage/extend-2.png'),
          name: '视频监控'
        },
        {
          key: 'biDescion',
          background: require('@/assets/indexPage/extend-3.png'),
          name: 'BI决策'
        },
        {
          key: 'wisdomBuild',
          background: require('@/assets/indexPage/extend-4.png'),
          name: '智慧建造',
          disabled: true
        }
      ],
      url: 'https://dashboard.cscecxn.com:8443/bigscreenv3/viewer/77fd3587-5bc2-4362-aa7e-9e87b36f933f',
      projectMapHost: process.env.VUE_APP_PM_BASEURL // 工程大数据host地址
    }
  },
  methods: {
    /**
     * @description: 详情
     * @param {Void} key 点击key
     * @return {Void}
     */
    handleDetail(key) {
      switch (key) {
        case 'video':
          this.$store.commit('SET_ACTIVE_CODES', ['syma', 'video', 'SPPZ', 'KZT'])
          this.$router.push({
            path: '/videoDocking/controPanel'
          })
          break
        case 'biDescion':
          window.open(this.url, '_blank')
          break
        case 'projectMap':
          // window.open(this.url2,'_blank')
          const token = Vue.getAcloudProvider().getAccessToken()
          const url = this.projectMapHost + `/auth-userapi/yyzhzx/api/authority/v1/token?accessToken=${token}&callback=${process.env.VUE_APP_PM_DATA}`
          window.open(url, '_blank')
          break
        default:
          this.$message.warning('暂未开放')
          break
      }
    }
  }
}
</script>

<style lang="less" scoped>
.extend-wrapper {
  display: flex;
  justify-content: space-between;
  padding: 0;
  margin: 0;
  li {
    position: relative;
    .show {
      position: absolute;
      z-index: 100;
      border: 1px solid #e8e8e8;
      box-shadow: 3px 2px 20px #ebebeb;
      padding: 0 10px;
      line-height: 24px;
      background-color: #fff;
      border-radius: 5px;
      font-size: 12px;
      left: 50%;
      margin-left: -23px;
      top: -26px;
      display: none;
      &::before {
        content: '';
        width: 0;
        height: 0;
        border: 8px solid;
        position: absolute;
        bottom: -18px;
        left: 50%;
        border-color: #e8e8e8 transparent transparent;
        margin-left: -10px;
      }
      &::after {
        content: '';
        width: 0;
        height: 0;
        border: 8px solid;
        position: absolute;
        bottom: -16px;
        left: 50%;
        border-color: #fff transparent transparent;
        margin-left: -10px;
      }
    }
  }
  li:nth-child(1) p {
    color: #ab7ee1;
  }
  li:nth-child(2) p {
    color: #0488c7;
  }
  li:nth-child(3) p {
    color: #05c5c7;
  }
  li:nth-child(4) p {
    color: #fd9f47;
  }
}
.disabled-card {
  position: relative;
  cursor: not-allowed !important;
  &::before {
    display: block;
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    background: rgba(0, 0, 0, 0.3);
  }
  .show {
    display: none !important;
  }
}
.extend-item {
  flex: 1;
  margin: 0 4px;
  position: relative;
  cursor: pointer;
  border-radius: 5px;
  &:nth-of-type(1) {
    margin-left: 0;
  }
  &:nth-last-of-type(1) {
    margin-right: 0;
  }
}
li:nth-child(3) {
  &:hover {
    .show {
      display: block;
    }
  }
}
.extend-item-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  & > p {
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 14px;
    background-color: #fff;
    margin: 0;
  }
}
.extend-item-bg {
  width: 100%;
}
.extend-item-image {
  height: calc(100% - 40px);
  position: relative;
  .extend-item-icon {
    width: 30%;
    position: absolute;
    top: 22%;
    left: 50%;
    margin-left: -16px;
  }
}
@media screen and (min-width: 1200) and (max-width: 1440px) {
  .extend-item-bg {
    min-height: 90px;
    object-fit: cover;
  }
}
</style>